@extends('app')
@section('content')
    <div class="jumbotron">
        <div class="container">
            <div class="media">
                <div class="media-left">
                    <a href="">
                        <img class="media-object img-circle" src="{{ $discussion->user->avatar }}" alt="64*64" style="width: 64px">
                    </a>
                </div>
                <div class="media-body">
                    <h4 class="media-heading">{{ $discussion->title }}</h4>
                    @if(Auth::check() && Auth::user()->id == $discussion->user_id)
                        <p><a class="btn btn-danger btn-lg pull-right" href="/discussion/{{ $discussion->id }}/edit" role="button">修改帖子 »</a></p>
                        @endif
                    {{ $discussion->user->name }}
                </div>
            </div>

        </div>
    </div>
    <div class="container">
        <div class="row">
            <div class="col-d-9" role="main">
                <div class="blog-post">
                    {!! $html !!}
                </div>
                <hr>
                @foreach($discussion->comments as $comment)
                    <div class="media">
                        <div class="media-left">
                            <a href="">
                                <img class="media-object img-circle" alt="64*64"  src="{{ $comment->user->avatar }}" style="height: 64px;width: 64px;">
                            </a>
                        </div>
                        <div class="media-body">
                            <h4 class="media-heading">{{ $comment->user->name }}</h4>
                            {{ $comment->body }}
                        </div>
                    </div>
                    @endforeach
                <hr>
                @if(Auth::check())
                {!! Form::open(['url'=>'/comment']) !!}
                {!! Form::hidden('discussion_id',$discussion->id) !!}
                <div class="form-group">
                    {!! Form::label('body','评论') !!}
                    {!! Form::textarea('body',null,['class'=>'form-control']) !!}
                </div>
                <div>
                    {!! Form::submit('发表评论',['class'=>'btn btn-success pull-right']) !!}
                </div>
                {!! Form::close() !!}
            </div>
            @else
                <a href="/user/login" class="btn btn-block btn-success">登录后发表评论</a>
            @endif
        </div>
    </div>
@stop
